#include "bsp.h"

void main(void)
{
	int ADCvalue = 0;
	float temp;
	
	WDTCTL = WDTPW + WDTHOLD;
	
	BSP_Init();
	
	REFCTL0   |= REFMSTR + REFVSEL_0 + REFON;    		// Enable internal 1.5V reference
	ADC12CTL0  = ADC12SHT03 + ADC12SHT02 + ADC12ON;	// Set sample and hold time and turn on the ADC
	ADC12CTL1  = ADC12SHP;
	ADC12MCTL0 = ADC12INCH_10;											// Set channel 10 (temp. sensor) to memory bank 0
	ADC12CTL0 |= ADC12ENC;													// Enable converstion
	
	while(1)
	{
		temp = 0;
		int i;
		for(i = 0; i < 5; i++)
		{
			ADC12CTL0 |= ADC12SC;												// Start conversion from ADC
			while(ADC12CTL1 & ADC12BUSY);								// Wait for the sample to complete
			ADCvalue = ADC12MEM0;
			temp += (ADCvalue-952)/3.586;								// empirically derived function
		}
		temp /= 5;
		__no_operation();
	}
}
